<?php 


	   $fbconfig['appid' ] = "491675174214499";
	   $fbconfig['secret'] = "0f2b15682d21ce22ac54700fd8a5724d";
	
	   $fbconfig['baseUrl']    =  HTML_BASE; 
	   $fbconfig['appBaseUrl'] =  "http://apps.facebook.com/146779032148660/";
		
		if (isset($_GET['code'])){
			header("Location: " . $fbconfig['appBaseUrl']);
			exit;
		}
	   
	   
		if (isset($_GET['request_ids'])){
			//user comes from invitation
			//track them if you need
		}
		
	   
		include_once "src/facebook.php";
		
		
	
	
	$facebook = new Facebook(array(
		  'appId'  => $fbconfig['appid'],
		  'secret' => $fbconfig['secret'],
		  'cookie' => true
		));
	
		//Facebook Authentication part
		$user = $facebook->getUser();
		
	
	
	
	if ($user) {
		
		/*$like_page = $facebook->api( array(
							 'method' => 'pages.isFan',
							 'page_id' => '570326972985204',
							 'uid' => $user,
						 ));*/
		  
		
	  try {
		 $logoutUrl = $facebook->getLogoutUrl();
		 $user = $facebook->getUser();
		 $user_profile = $facebook->api('/me');
		
		
					
		  
	  } catch (FacebookApiException $e) {
		  
		//echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
		//$user = null;
	  
	  }
	  
	}


?>